]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/settings: Add API to inhibit animations
authorJonas Ådahl <jadahl@gmail.com>
Tue, 1 Oct 2019 09:56:34 +0000 (11:56 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Thu, 20 Feb 2020 11:14:55 +0000 (11:14 +0000)
There may be situations where we shouldn't enable animations. Make it
possible for the Shell to decide when there are such situations and in
when needed inhibit animations.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757

src/st/st-settings.c
src/st/st-settings.h

index d0fef040ab1304e041598cc1fedf13b3a087ab45..5ce73d015347d2d39438633d40356ccb745b386e 100644 (file)
@@ -60,6 +60,7 @@ struct _StSettings
   gchar *font_name;
   gchar *gtk_theme;
   gchar *gtk_icon_theme;
+  int inhibit_animations_count;
   gboolean enable_animations;
   gboolean primary_paste;
   gboolean magnifier_active;
@@ -82,6 +83,41 @@ st_settings_set_slow_down_factor (StSettings *settings,
   g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_SLOW_DOWN_FACTOR]);
 }
 
+static gboolean
+get_enable_animations (StSettings *settings)
+{
+  if (settings->inhibit_animations_count > 0)
+    return FALSE;
+  else
+    return settings->enable_animations;
+}
+
+void
+st_settings_inhibit_animations (StSettings *settings)
+{
+  gboolean enable_animations;
+
+  enable_animations = get_enable_animations (settings);
+  settings->inhibit_animations_count++;
+
+  if (enable_animations != get_enable_animations (settings))
+    g_object_notify_by_pspec (G_OBJECT (settings),
+                              props[PROP_ENABLE_ANIMATIONS]);
+}
+
+void
+st_settings_uninhibit_animations (StSettings *settings)
+{
+  gboolean enable_animations;
+
+  enable_animations = get_enable_animations (settings);
+  settings->inhibit_animations_count--;
+
+  if (enable_animations != get_enable_animations (settings))
+    g_object_notify_by_pspec (G_OBJECT (settings),
+                              props[PROP_ENABLE_ANIMATIONS]);
+}
+
 static void
 st_settings_finalize (GObject *object)
 {
@@ -126,7 +162,7 @@ st_settings_get_property (GObject    *object,
   switch (prop_id)
     {
     case PROP_ENABLE_ANIMATIONS:
-      g_value_set_boolean (value, settings->enable_animations);
+      g_value_set_boolean (value, get_enable_animations (settings));
       break;
     case PROP_PRIMARY_PASTE:
       g_value_set_boolean (value, settings->primary_paste);
index c2c4fa23e06252469395ec00ef0456531009e814..8b25494699596e3dd4e7afb1453878fb56d24c1c 100644 (file)
@@ -33,6 +33,10 @@ G_DECLARE_FINAL_TYPE (StSettings, st_settings, ST, SETTINGS, GObject)
 
 StSettings * st_settings_get (void);
 
+void st_settings_inhibit_animations (StSettings *settings);
+
+void st_settings_uninhibit_animations (StSettings *settings);
+
 G_END_DECLS
 
 #endif /* __ST_SETTINGS_H__ */